package article

import (
	"gitee.com/golang_study/goblog/pkg/route"
	"gitee.com/golang_study/goblog/pkg/types"
)

// Article 文章模型
type Article struct {
	ID    uint64
	Title string
	Body  string
	CategoryID uint64 `gorm:"not null;default:4;index"`
}

// Link 方法用来生成文章链接
func (article Article) Link() string {
	return route.Name2URL("articles.show", "id", article.GetStringID())
}

// GetStringID 获取 ID 的字符串格式
func (article Article) GetStringID() string {
	return types.Uint64ToString(article.ID)
}